#可以利用datetime函数判断日期是否合法

from datetime import datetime
def valid_date(year, month, day):
    try:
        datetime(year, month, day)
        return True
    except ValueError:
        return False
def find_dates(date_str):
    parts = date_str.split('/')
    AA, BB, CC = map(int, parts)
    century= [19, 20]
    possible_dates = set()
    for prefix in century:
        year = prefix * 100 + AA
        if 1960 <= year <= 2059:
            if valid_date(year, BB, CC):
                possible_dates.add(f"{year:04d}-{BB:02d}-{CC:02d}")
        year = prefix * 100 + CC
        if 1960 <= year <= 2059:
            if valid_date(year, AA, BB):
                possible_dates.add(f"{year:04d}-{AA:02d}-{BB:02d}")
            # 日/年/月
            if valid_date(year, BB, AA):
                possible_dates.add(f"{year:04d}-{BB:02d}-{AA:02d}")
    sorted_dates = sorted(possible_dates)
    for date in sorted_dates:
        print(date)

# 示例使用
find_dates(input())